﻿Imports TNCDAL
Imports System.Data.Linq
Imports System.Linq


Public Class CComercialInvoice
    Dim db As New TanNamChinhDataContext

    Public Function SelectRecordById(ByVal id As Integer) As tblComercialInvoice
        Dim ci = (From p In db.tblComercialInvoices
                 Where p.ID_ComercialInvoice = id
                 Select p).Single
        Return ci
    End Function

    Public Sub Insert(ByVal obj As tblComercialInvoice)
        db.tblComercialInvoices.InsertOnSubmit(obj)
        db.SubmitChanges()
    End Sub

    Public Sub Update(ByVal obj As tblComercialInvoice)
        Dim ci = SelectRecordById(obj.ID_ComercialInvoice)
        ci.ComercialInvoiceNo = obj.ComercialInvoiceNo
        ci.CreateDate = obj.CreateDate
        ci.DeliveryTo = obj.DeliveryTo
        ci.DescriptionOfCont = obj.DescriptionOfCont
        ci.ID_Country = obj.ID_Country
        ci.ID_Currency = obj.ID_Currency
        ci.Ratio = obj.Ratio
        ci.UnitTermPriceCNEE = obj.UnitTermPriceCNEE
        ci.UnitTermPriceHQ = obj.UnitTermPriceHQ
        db.SubmitChanges()
    End Sub

    Public Sub Delete(ByVal id As Integer)
        Dim ac = SelectRecordById(id)
        db.tblComercialInvoices.DeleteOnSubmit(ac)
        db.SubmitChanges()
    End Sub
End Class
